//
//  EmotionKeyboardCell.swift
//  MyWeiBo
//
//  Created by mac on 15/3/13.
//  Copyright (c) 2015年 gpr. All rights reserved.
//

import UIKit

class EmotionKeyboardCell: UICollectionViewCell {
    static let ID = "EmotionKeyboardCell"
    
    class func emotionKeyboardCellWithCollectionView(collectionView: UICollectionView, indexPath: NSIndexPath) -> EmotionKeyboardCell {
        return collectionView.dequeueReusableCellWithReuseIdentifier(ID, forIndexPath: indexPath) as! EmotionKeyboardCell
    }
    
    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var emojiLabel: UILabel!
    
    var emotion: Emoticon? {
        didSet {
            if emotion!.isNone {
                emojiLabel.hidden = true
                iconImageView.hidden = true
                return
            }
            if emotion!.isDelete {
                emojiLabel.hidden = true
                iconImageView.hidden = false
                iconImageView.image = UIImage(named: "compose_emotion_delete_highlighted")
                return
            }
            if emotion?.type == 1 { // emoji
                emojiLabel.hidden = false
                iconImageView.hidden = true
                emojiLabel.text = emotion!.emoji
            } else {    // 图片表情
                emojiLabel.hidden = true
                iconImageView.hidden = false
                iconImageView.image = UIImage(contentsOfFile: emotion!.imagePath!)
            }
        }
    }
}
